package com.yz.food.controller;

import com.yz.food.pojo.Category;
import com.yz.food.pojo.Doubt;
import com.yz.food.service.CategoryService;
import com.yz.food.service.DoubtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class DoubtController {
    @Autowired
    private DoubtService doubtService;
    @Autowired
    private CategoryService categoryService;

    /**
     * 跳转到问答页面
     */
    @RequestMapping("page/doubt")
    public String answer(ModelMap modelMap) {
        List<Doubt> doubtList = doubtService.getAll();
        modelMap.addAttribute("doubtList", doubtList);
        List<Category> categories = categoryService.getAll();
        modelMap.addAttribute("categories", categories);
        return "questionAndAnswer";
    }
}
